<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
  <title></title>
  <script language="javascript" src="http://webapi.amap.com/maps?v=1.3&amp;key=e8496e8ac4b0f01100b98da5bde96597"></script>
  <script src="./address.js"></script>
</head>
<body>

<a id="distance" onclick="getDistance()">获取距离</a>
<script>
  //获取当前位置(方法名)
  mMap.getSessionLocation(locationFunc);
  function locationFunc(){
    var data = JSON.parse(sessionStorage.getItem("location"));
    //逆地理编码
    var lnglatXY = [data.position.lng, data.position.lat];//地图上所标点的坐标
    geocoder.getAddress(lnglatXY, function(status, result){
      if(status === 'complete' && result.info === 'OK'){
        //获得了有效的地址信息:
        alert(result.regeocode.formattedAddress);
      }else{
        //获取地址失败
        alert("999");
      }
    });

  }
//
//  // 获取两点的距离 (m)
//  function getDistance(){
//    var obj1={lng:116.39,lat: 39.98};
//    var obj2={lng:116.39,lat: 38.98};
//    alert(mMap.distance(obj1,obj2));
//    mMap.serverDistance(obj1,obj2);
//  }
</script>
</body>
</html>